"""initial

Revision ID: c2addcb80378
Revises: 
Create Date: 2024-05-18 04:49:05.411048

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "4274059f8363"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("CREATE SCHEMA auth;")
    op.create_table(
        "users",
        sa.Column("name", sa.String(length=128), nullable=True),
        sa.Column("surname", sa.String(length=128), nullable=True),
        sa.Column("login", sa.String(length=128), nullable=False),
        sa.Column("email", sa.String(length=128), nullable=True),
        sa.Column("password", sa.String(length=128), nullable=False),
        sa.Column("uuid", sa.UUID(), nullable=False),
        sa.Column("create_at", sa.DateTime(), nullable=False),
        sa.Column("update_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("uuid"),
        sa.UniqueConstraint("email"),
        sa.UniqueConstraint("login"),
        schema="auth",
    )
    op.create_table(
        "account",
        sa.Column("uuid", sa.UUID(), nullable=False),
        sa.Column("user_uuid", sa.UUID(), nullable=True),
        sa.Column("login_time", sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_uuid"], ["auth.users.uuid"], ondelete="CASCADE"
        ),
        sa.PrimaryKeyConstraint("uuid"),
        schema="auth",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("account", schema="auth")
    op.drop_table("users", schema="auth")
    # ### end Alembic commands ###
